﻿using System;
using System.Linq;

namespace Extentions
{
    public static partial class Linq
    {
        /// <summary>
        ///Returns if the specified source is any of.
        ///if (flag == 1 && flag == 2 && flag == 3 && flag == 4) { .. }
        ///if (flag.IsAll(1, 2, 3, 4)) { .. }
        ///true.IsAll(1==1,44==44); is true
        ///false.IsAll(1==1,2==4); is true
        ///1.IsAll(1 - 2 + 2, 1); is true
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        /// <param name="parms"></param>
        /// <returns></returns>
        public static bool IsAll<T>(this T source, params T[] parms)
        {
            if (source == null) throw new ArgumentNullException("source");
            return parms.Count(x => x.Equals(source)) == parms.Count();
        }
    }
}